// components/choiceTime/index.js
import {
    formatDate
} from '../../utils/util'
var currentDate = new Date();
Component({

    /**
     * 组件的属性列表
     */
    properties: {},
    lifetimes: {
        attached: function () {
            // 在组件加载时调用 methods 里的方法  
            this.getCurrentDay()
        }
    },

    /**
     * 组件的初始数据
     */
    data: {
        curTime: ''
    },

    /**
     * 组件的方法列表
     */
    methods: {
        theDayBefore() {
            currentDate.setDate(currentDate.getDate() - 1);
            this.getCurrentDay()
            this.triggerEvent('time', formatDate(currentDate))
        },
        theNextDay() {
            currentDate.setDate(currentDate.getDate() + 1);
            this.getCurrentDay()
            this.triggerEvent('time', formatDate(currentDate))
        },
        getCurrentDay() {
            this.setData({
                curTime: formatDate(currentDate)
            })
        },
    }
})